<?php

namespace app\data\controller\api;

use think\admin\Controller;

/**
 * 海报接口控制器
 * Class Ad
 * @package app\data\controller\api
 */
class Poster extends Controller
{
    /**
     * 获取海报数据列表
     */
    public function getItem()
    {
        $query = $this->app->db->table('data_invite_posters');
        $result = $query->where(['deleted' => 0, 'status' => 1])->withoutField('deleted,create_at,update_at,status')->order('sort desc, id desc')->select();
        $this->success('获取海报数据列表成功', $result);
    }

    /**
     * 获取海报详情数据
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getAdDetail()
    {
        $query = $this->app->db->table('data_invite_posters')->where('id', input('id'));
        $result = $query->where(['deleted' => 0, 'status' => 1])->withoutField('deleted,create_at,update_at,status')->find();
        $this->success('获取海报数据成功', $result ?: []);
    }
}